<template>
  <div>
    <!-- 添加 -->
    <div>
      <el-form :inline="true">
        <el-form-item>
          <el-button type="primary" @click="addbutton">添加</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 展示s -->
    <div>
      <el-table
        :data="creditList"
        style="width: 150%; margin: 0 auto"
        align="right"
      >
      <el-table-column
          prop="coreEnterprise.id"
          label="公司编号"
          width="80"
          align="center"
        >
         </el-table-column>
         <el-table-column
          prop="merchandiser.id"
          label="业务员编号"
          width="80"
          align="center"
        >
         </el-table-column>
        <el-table-column
          prop="loanProductName"
          label="贷款产品名称"
          width="140"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="taskStartTime"
          label="任务开始时间"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="taskEndTime"
          label="任务结束时间"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="creditLine"
          label="授信额度"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="effectiveStart"
          label="生效起始日"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="effectiveEnd"
          label="生效截止日"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="opinionResult"
          label="处理意见"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="opinionComment"
          label="意见内容"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="state" label="状态" width="120" align="center">
          
        </el-table-column>
        <!-- <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              icon="el-icon-edit"
              @click="handleEdit(scope.$index, scope.row)"
              >编辑</el-button
            >
            <el-button
              size="mini"
              icon="el-icon-delete"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column> -->
      </el-table>
    </div>
    <!-- 模态框 -->
    <div>
      <el-dialog
        :title="title"
        :visible.sync="dialogFormVisible"
        @close="closeDialog"
      >
        <el-form
          :inline="true"
          ref="enterpriseCredit"
          :model="enterpriseCredit"
        >
        <el-form-item label="核心企业信息" prop="coreEnterprise">
            <el-input
              v-model="enterpriseCredit.coreEnterprise.id"
              placeholder="核心企业信息"
            ></el-input>
          </el-form-item>
          <el-form-item label="业务员" prop="merchandiser_id">
            <el-input
              v-model="enterpriseCredit.merchandiser.id"
              placeholder="业务员"
            ></el-input>
          </el-form-item>
          <el-form-item label="授信额度" prop="credit_line">
            <el-input
              v-model="enterpriseCredit.creditLine"
              placeholder="授信额度"
            ></el-input>
          </el-form-item>
          <el-form-item label="生效起始日" prop="effective_start">
            <el-date-picker
              v-model="enterpriseCredit.effectiveStart"
              type="datetime"
              placeholder="选择日期时间"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="生效截止日" prop="effective_end">
            <el-date-picker
              v-model="enterpriseCredit.effectiveEnd"
              type="datetime"
              placeholder="选择日期时间"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="状态" prop="state">
            <el-input
              v-model="enterpriseCredit.state"
              placeholder="状态"
            ></el-input>
          </el-form-item>
        </el-form>

        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="add('enterpriseCredit')"
            >确 定</el-button
          >
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  name: "VseSupplyChainEnterprisecredit",

  data() {
    return {
      creditList: [],
      enterpriseCredit: {
        coreEnterprise:{
          id:""
        },
        merchandiser:{
          id:""
        },
        credit_line:"",
        effectiveStart:"",
        effectiveEnd:"",
        loanProductName:"",
        taskStartTime: "",
        taskEndTime: "",
        state: "",
      },
      title: "",
      dialogFormVisible: false,
    };
  },

  created: function () {
    //调用方法
    this.findAll();
  },

  mounted() {},

  methods: {
    //到后台获取列表数据
    findAll: function () {
      this.$axios
        .get("http://localhost:8800/enterprisecredit/findall")
        .then((result) => {
          console.log(result);
          console.log(result.data);
          this.creditList = result.data;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    add: function () {
      this.$axios
        .post(
          "http://localhost:8800/enterprisecredit/add/",
          this.enterpriseCredit
        )
        .then((result) => {
          this.dialogFormVisible = false;
          console.log(result);
          this.findAll();
          this.$message("添加成功");
        });
    },
    showFlow: function (id) {
      this.$axios
        .get("http://localhost:8800/flow/findFlowTask/" + id)
        .then(function (result) {
          console.log(result);
        });
    },
    open() {
      this.$prompt("请输入邮箱", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then(({ value }) => {
          this.$message({
            type: "success",
            message: "你的邮箱是: " + value,
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入",
          });
        });
    },
    addbutton() {
      (this.title = "添加"), (this.dialogFormVisible = true);
    },
    closeDialog() {
      this.enterpriseCredit = {};
      this.$refs["enterpriseCredit"].clearValidate();
    },
  },
};
</script>

<style lang="scss" scoped>

</style>